package selectionweb.web;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import selectionweb.web.repository.IngredientRepository;

@SpringBootApplication
public class WebApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
    @Bean
    public CommandLineRunner dataLoader(IngredientRepository repo) {
        return new CommandLineRunner() {
            @Override
            public void run(String... args) throws Exception {
                repo.save(new Ingredient("语文", "语文", Ingredient.Type.SUBJECT));
                repo.save(new Ingredient("数学", "数学", Ingredient.Type.SUBJECT));
                repo.save(new Ingredient("英语", "英语", Ingredient.Type.SUBJECT));
                repo.save(new Ingredient("物理", "物理", Ingredient.Type.SUBJECT));
                repo.save(new Ingredient("化学", "化学", Ingredient.Type.SUBJECT));
                repo.save(new Ingredient("生物", "生物", Ingredient.Type.SUBJECT));
            }
        };
    }
}
